<?php
namespace Admin\Controller;
use Think\Controller;
class AjaxController extends Controller {
   

    /**
     * undocumented function
     *
     * @return void
     * @author 
     **/
    function getCode()
    {
    	$Verify = new \Think\Verify();
    	$Verify->fontSize = 20;
    	$Verify->length   = 4;
    	ob_clean();
    	$Verify->entry();
    }

    /**
     * 短信验证码
     *
     * @return void
     * @author 
     **/
    function send_sms()
    {
        vendor('sms.httpUtil');//手动加载第三方类库
        $http = new \httpUtil;
        // var_dump($http);die;
        $funAndOperate = "industrySMS/sendSMS";

        // 参数详述请参考http://miaodiyun.com/https-xinxichaxun.html

        // 生成body
        $body = $http->createBasicAuthData();
        $code = mt_rand(1000,9999);
        // print_r($body);die;
        // 在基本认证参数的基础上添加短信内容和发送目标号码的参数
        session('sms_code',$code);
        $body['smsContent'] = "【云海科技】登录验证码：".$code."，如非本人操作，请忽略此短信。";
        // print_r(I('post.tel'));die;
        $body['to'] = I('post.tel');

        // 提交请求
        $result = $http->post($funAndOperate, $body);
        // var_dump($result);
        $status = json_decode($result,true)['respCode'];//返回短信状态
        echo ($status=='00000')?1:0;
        // echo $status;
    }
    
   }